Repository navigation
Run always uses the current project files; reset command restarts Python - #31
Merged
Merged
Conversation
A file removed or renamed since the last Run stayed importable under its old name: its module was only dropped if the file was still mounted, so `import helfer` kept running the old code instead of raising ModuleNotFoundError as CPython does. _glpython_invalidate_modules now also drops the modules of the files mounted the time before, clears the import system's caches, and no bytecode is written (no stale .pyc for a file changed within a second). Applies to Run, Tests and Visualize. check-runtime-imports.py: changed files (same size, at once), a new file, a removed and a renamed file, parser.py imported through auswerter.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
{ type: 'reset' } only cleared the console and the visualization; Python
kept its namespace. It now does what Reset does (restart and clear), so a
host can offer it elsewhere - the IDE's «Python neu starten» in its menu.
The embed is unaffected: its Reset remounts the workspace.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two small changes for the next release (v0.1.12). The import fix is needed in the IDE before Etappe 4 (v0.1.12 bump after this PR).
1. No stale imported modules (needed before Etappe 4)
The question: does ▶ Ausführen reload changed imported project files (e.g.
parser.pynext toauswerter.py)?Measured in Pyodide (programs of several files, run in quick succession):
mainhelfer.pychanged, same size, run right away (twice)helfer.pyremoved,import helferwert 40)ModuleNotFoundError: No module named 'helfer'helfer2.py, old name importedModuleNotFoundErrorChanged files were always reloaded: each Run, Tests and Visualize drops the modules of the files it mounts. The modules of files mounted the time before stayed, though, so a removed or renamed file kept running its old code under its old name. CPython would raise
ModuleNotFoundError.Fix (
session.py):_glpython_invalidate_modulesremembers the paths mounted last time and drops their modules too.importlib.invalidate_caches().sys.dont_write_bytecode = True, so no stale.pycis possible for a file changed within the same second.The new
scripts/check-runtime-imports.py(intest:runtime) covers changed files (same size, right away), a new file, a removed and a renamed file, andparser.pychanged underneathauswerter.py. It fails onmainwith exactly the two stale cases.2.
{ type: 'reset' }restarts PythonThe workspace command
resetonly cleared the console and the visualization. It now does what the Reset button does: restart Python and clear the console. The embed is unaffected, since its Reset remounts the workspace. The IDE's «Python neu starten» (glpython-edu/glpython-edu.github.io#16) remounts the workspace for now, because it pins v0.1.11. It can switch to this command, which avoids remounting the editor, with the v0.1.12 bump.Lint (known warning only), both builds,
test:protocol,test:runtime(now 9 scripts) andtest:hintspass.🤖 Generated with Claude Code